using System;
using System.Linq;
using Caramel.Entities;

namespace Caramel.FluentNHibernate.Conventions
{
	public class PersonConvention : global::FluentNHibernate.Conventions.IPropertyConvention
	{
		#region IConvention<IPropertyInspector,IPropertyInstance> Members

		public void Apply(global::FluentNHibernate.Conventions.Instances.IPropertyInstance instance)
		{
			if (typeof(IPerson).IsAssignableFrom(instance.Property.DeclaringType) && (new[] { "Prefix", "Suffix" }.Contains(instance.Property.Name)))
			{
				instance.Nullable();
			}
		}

		#endregion
	}
}
